package com.example.service.impl;

import com.example.dao.RoleDao;
import com.example.pojo.Role;
import com.example.service.RoleService;
import org.springframework.stereotype.Service;

/**
 * roleService
 * 通过注解方式实现spring Bean管理
 */
@Service
public class RoleServiceImpl implements RoleService {
    private RoleDao mapper;

    public void setMapper(RoleDao mapper) {
        this.mapper = mapper;
    }

    @Override
    public void addOne(Role role) {
        System.out.println("正在执行addOne");
        mapper.add(role);
        throw new RuntimeException("人为添加异常,依靠事务进行回滚");
    }

    @Override
    public void deleteOne() {
        System.out.println("正在执行deleteOne");
    }

    @Override
    public Role findOne(int id) {
        return mapper.find(id);
    }
}
